home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / pyshared / nevow / livetest-postscripts.js < prev    next >
Text File  |  2005-07-11  |  2KB  |  50 lines

  1.  
  2. var testFrameNode = document.getElementById('testframe');
  3. testFrameNode.addEventListener('load', loadNotify, true);
  4.  
  5. var sendSubmitEvent = function(theTarget, callWhenDone) {
  6.     var theEvent = testFrameNode.contentDocument.createEvent("HTMLEvents");
  7.     theEvent.initEvent("submit",
  8.         true,
  9.         true);
  10.     theTarget.dispatchEvent(theEvent);
  11.     callWhenDone()
  12. }
  13.  
  14. var ifTesteeUsingLivePage = function(runThisCode, otherwise) {
  15.     if (testFrameNode.contentDocument.defaultView.listenForInputEvents) {
  16.         runThisCode()
  17.     } else {
  18.         otherwise()
  19.     }
  20. }
  21.  
  22. var sendClickEvent = function(theTarget, callWhenDone) {
  23.     var doEventOfType = function(eventType) {
  24.         var theEvent = testFrameNode.contentDocument.createEvent("MouseEvents");
  25.         var evt = document.createEvent("MouseEvents")
  26.         evt.initMouseEvent(eventType,
  27.             true, //can bubble
  28.             true,
  29.             window,
  30.             1,
  31.             theTarget.offsetLeft + theTarget.offsetWidth / 2 + window.screenX, //screen x
  32.             theTarget.offsetTop + theTarget.offsetTop / 2 + window.screenY, //screen y
  33.             theTarget.offsetLeft + theTarget.offsetWidth / 2, //client x
  34.             theTarget.offsetTop + theTarget.offsetTop / 2, //client y
  35.             false,
  36.             false,
  37.             false,
  38.             false,
  39.             1,
  40.             theTarget);
  41.  
  42.         theTarget.dispatchEvent(evt);
  43.     }
  44.     doEventOfType('mousedown');
  45.     doEventOfType('mouseup');
  46.     doEventOfType('click');
  47.     callWhenDone();
  48. }
  49.  
  50.